﻿using System;
using System.Linq;

namespace Yozeev.Common.Generators
{
    /// <summary>
    /// 取票码生成器
    /// </summary>
    public class ActivityCodeGenerator : IGenerator
    {
        /// <summary>
        /// 随机生成取票码
        /// </summary>
        /// <returns></returns>
        public string Gen(int length)
        {
            Random generator = new Random();
            String r = generator.Next(0, 100000000).ToString("D6");
            if (r.Distinct().Count() == 1)
            {
                r = Gen(length);
            }
            return r;
        }
    }
}
